#include "iso_sprite.h"

#include "bn_sprite_builder.h"

#include "tools.h"

static bn::sprite_ptr getSpriteFromBuilder(const bn::sprite_item& item, const int itemX, const int itemY)
{
    bn::sprite_builder builder{item};
    builder.set_x(itemX);
    builder.set_y(itemY);
    return builder.release_build();
}

sprite::sprite(const int posX, const int posY, const bn::sprite_item& spriteItem)
    : currentPosX{posX}
    , currentPosY{posY}
    , spritePtr{getSpriteFromBuilder(spriteItem, posX, posY)}
{

}

void sprite::setX(const int x)
{
    currentPosX = x;
}

void sprite::setX(const bn::fixed& x)
{
    currentPosX = x.data();
}

void sprite::setY(const int y)
{
    currentPosY = y;
}

void sprite::setY(const bn::fixed& y)
{
    currentPosY = y.data();
}

void sprite::setZOrder(const int z)
{
    spritePtr.set_z_order(z);
}

int sprite::getX()
{
    return currentPosX;
}

int sprite::getY()
{
    return currentPosY;
}

int sprite::getZOrder()
{
    return spritePtr.z_order();
}

bn::fixed_point sprite::getCurrentCoords()
{
    return bn::fixed_point{currentPosX, currentPosY};
}

bn::sprite_ptr& sprite::getSpritePtr()
{
    return spritePtr;
}
